year = eval(input("请输入年份:"))
week1 = eval(input("请输入星期几："))

isLeap = (year%4==0 and year %100 !=0) or (year%400==0)

day = 0
for i in range(1,13):
    week = (day % 7 + week1) % 7
    if i==1 or i==3 or i==5 or i==7 or i==8 or i==10 or i==12:
        day += 31
        month_day = 31
    elif i==2:
        if isLeap:
            day += 29
            month_day = 29
        else:
            day += 28
            month_day = 28
    else:
        day += 30
        month_day = 30

    print(format("一月" if i==1 \
        else "二月" if i==2 \
        else "三月" if i==3 \
        else "四月" if i==4 \
        else "五月" if i==5 \
        else "六月" if i==6 \
        else "七月" if i==7 \
        else "八月" if i==8 \
        else "九月" if i==9 \
        else "十月" if i==10 \
        else "冬月" if i==11 \
        else "腊月",">24s"),year)
    print("-"*60)
    print(format("星期天","6s"),\
          format("星期天","6s"),\
          format("星期一","6s"),\
          format("星期二","6s"),\
          format("星期三","6s"),\
          format("星期四","6s"),\
          format("星期五","6s"),\
          format("星期六","6s")
    )

    index = 0
    for i in range(0,week):
        print(format("","12s"),end='')
        index += 1
    for i in range(1,month_day+1):
        print(format(i,"<12d"),end='')
        index += 1
        if index % 7 ==0:
            print()

    print()
    print()


